package com.moon.game.command.guest.lair;

import java.util.ArrayList;
import java.util.List;

import com.moon.game.command.BaseCmd;
import com.moon.game.command.RequestSession;
import com.moon.game.constants.Constants;
import com.moon.game.exception.GException;
import com.moon.game.vos.PlayerVo;
import com.moon.game.vos.PlayerVo.Pet;

/**
 * @description 查看我的宠物列表
 * @author Ranger 作者 E-mail:haozi000005@163.com
 * @version 创建时间：2012-7-21 下午3:05:05
 */
public class ShowMyPetsCmd extends BaseCmd{

	@Override
	protected void runOnce(RequestSession req) throws GException {
		switch (req.getStatus()) {
			case STATU_INIT:
				doInit(req);
				break;
			case STATU_CHECK:
				doCheckSelf(req);
				break;
			case STATU_RETURN:
				doResponse(req);
				break;
			default:
				break;
		}
	}

	@Override
	protected void doResponse(RequestSession req) throws GException {
		PlayerVo player = req.getPlayer();
		List<Pet> pets = player.getPetList();
		if (pets == null) {
			pets = new ArrayList<Pet>();
		}
		
		req.setVO("pets", pets);
		//返回当前我的宠物园容量
		req.setVO("pet_yard_capacity", player.getPetYardCapacity());
		req.setVO("left_capacity", player.getPetYardCapacity() - pets.size());
		req.setVO("max_capacity", Constants.MAX_PET_YARD_CAPACITY);
		//返回
		response(req, req.getClientResponse());
	}
}
